package kankan.wheel.widget;

import kankan.wheel.R;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.WindowManager;

public class SimpleWheelView extends WheelView {
	
	private Paint mLinePaint = new Paint();
	private int mLineStartX;
	private int mLineEndX;
	
	/**
	 * Constructor
	 */
	public SimpleWheelView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		mLinePaint.setColor(0xffcf2134);
		mLinePaint.setStrokeWidth(3);
	}

	/**
	 * Constructor
	 */
	public SimpleWheelView(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	/**
	 * Constructor
	 */
	public SimpleWheelView(Context context) {
		this(context, null);
	}
	
	/**
	 * Initializes resources
	 */
	@Override
	protected void initResourcesIfNecessary() {
		if (centerDrawable == null) {
//			centerDrawable = getContext().getResources().getDrawable(R.drawable.simple_wheel_val);
		}

		if (topShadow == null) {
//			topShadow = new GradientDrawable(Orientation.TOP_BOTTOM, SHADOWS_COLORS);
		}

		if (bottomShadow == null) {
//			bottomShadow = new GradientDrawable(Orientation.BOTTOM_TOP, SHADOWS_COLORS);
		}

		setBackgroundResource(R.drawable.simple_wheel_bg);
	}
	
	/**
	 * Draws rect for current value
	 * @param canvas the canvas for drawing
	 */
	protected void drawCenterRect(Canvas canvas) {
		int center = getHeight() / 2;
		int offset = (int) (getItemHeight() / 2 * 1.2);
//		centerDrawable.setBounds(0, center - offset, getWidth(), center + offset);
//		centerDrawable.draw(canvas);
		
		if(mLineStartX == 0 || mLineEndX == 0) {
			final int viewWidth = getWidth();
			final int percentWidth = viewWidth * 60 / 100;
			mLineStartX = (viewWidth - percentWidth) / 2;
			mLineEndX = mLineStartX + percentWidth;
		}
		
		canvas.drawLine(mLineStartX, center - offset, mLineEndX, center - offset, mLinePaint);
		canvas.drawLine(mLineStartX, center + offset, mLineEndX, center + offset, mLinePaint);
	}

//	protected void drawShadows(Canvas canvas) {
//		int height = (int)(1.5 * getItemHeight());
//	}

//--------------------------------------------------	
}
